Skip to main content

Node Event

Description:

  The available event slots for a Node. This is just a demonstration record showing the signal slot names and callbacks.

Usage:

-- you can register for these events using codes like:
node:slot("ActionEnd", function(action: Action, target: Node)
print("Action end", action, target)
end)

ActionEnd

Type: Node Event.

Description:

  The ActionEnd slot is triggered when an action is finished. Triggers after node:runAction() and node:perform().

Signature:

["ActionEnd"]: function(action: Action, target: Node)

Parameters:

ParameterTypeDescription
actionActionThe finished action.
targetNodeThe node that finished the action.

TapFilter

Type: Node Event.

Description:

  The TapFilter slot is triggered before the TapBegan slot and can be used to filter out certain taps. Triggers after setting node.touchEnabled = true.

Signature:

["TapFilter"]: function(touch: Touch)

Parameters:

ParameterTypeDescription
touchTouchThe touch that triggered the tap.

TapBegan

Type: Node Event.

Description:

  The TapBegan slot is triggered when a tap is detected. Triggers after setting node.touchEnabled = true.

Signature:

["TapBegan"]: function(touch: Touch)

Parameters:

ParameterTypeDescription
touchTouchThe touch that triggered the tap.

TapEnded

Type: Node Event.

Description:

  The TapEnded slot is triggered when a tap ends. Triggers after setting node.touchEnabled = true.

Signature:

["TapEnded"]: function(touch: Touch)

Parameters:

ParameterTypeDescription
touchTouchThe touch that triggered the tap.

Tapped

Type: Node Event.

Description:

  The Tapped slot is triggered when a tap is detected and has ended. Triggers after setting node.touchEnabled = true.

Signature:

["Tapped"]: function(touch: Touch)

Parameters:

ParameterTypeDescription
touchTouchThe touch that triggered the tap.

TapMoved

Type: Node Event.

Description:

  The TapMoved slot is triggered when a tap moves. Triggers after setting node.touchEnabled = true.

Signature:

["TapMoved"]: function(touch: Touch)

Parameters:

ParameterTypeDescription
touchTouchThe touch that triggered the tap.

MouseWheel

Type: Node Event.

Description:

  The MouseWheel slot is triggered when the mouse wheel is scrolled. Triggers after setting node.touchEnabled = true.

Signature:

["MouseWheel"]: function(delta: Vec2)

Parameters:

ParameterTypeDescription
deltaVec2The amount of scrolling that occurred.

Gesture

Type: Node Event.

Description:

  The Gesture slot is triggered when a gesture is recognized. Triggers after setting node.touchEnabled = true.

Signature:

["Gesture"]: function(center: Vec2, numFingers: integer, deltaDist: number, deltaAngle: number)

Parameters:

ParameterTypeDescription
centerVec2The center of the gesture.
numFingersintegerThe number of fingers involved in the gesture.
deltaDistnumberThe distance the gesture has moved.
deltaAnglenumberThe angle of the gesture.

Enter

Type: Node Event.

Description:

  The Enter slot is triggered when a node is added to the scene graph. Triggers when doing node:addChild().

Signature:

["Enter"]: function()

Exit

Type: Node Event.

Description:

  The Exit slot is triggered when a node is removed from the scene graph. Triggers when doing node:removeChild().

Signature:

["Exit"]: function()

Cleanup

Type: Node Event.

Description:

  The Cleanup slot is triggered when a node is cleaned up. Triggers only when doing parent:removeChild(node, true).

Signature:

["Cleanup"]: function()

KeyDown

Type: Node Event.

Description:

  The KeyDown slot is triggered when a key is pressed down. Triggers after setting node.keyboardEnabled = true.

Signature:

["KeyDown"]: function(keyName: Keyboard.KeyName)

Parameters:

ParameterTypeDescription
keyNameKeyboard.KeyNameThe name of the key that was pressed.

KeyUp

Type: Node Event.

Description:

  The KeyUp slot is triggered when a key is released. Triggers after setting node.keyboardEnabled = true.

Signature:

["KeyUp"]: function(keyName: Keyboard.KeyName)

Parameters:

ParameterTypeDescription
keyNameKeyboard.KeyNameThe name of the key that was released.

KeyPressed

Type: Node Event.

Description:

  The KeyPressed slot is triggered when a key is pressed. Triggers after setting node.keyboardEnabled = true.

Signature:

["KeyPressed"]: function(keyName: Keyboard.KeyName)

Parameters:

ParameterTypeDescription
keyNameKeyboard.KeyNameThe name of the key that was pressed.

AttachIME

Type: Node Event.

Description:

  The AttachIME slot is triggered when the input method editor (IME) is attached (calling node:attachIME()).

Signature:

["AttachIME"]: function()

DetachIME

Type: Node Event.

Description:

  The DetachIME slot is triggered when the input method editor (IME) is detached (calling node:detachIME() or manually closing IME).

Signature:

["DetachIME"]: function()

TextInput

Type: Node Event.

Description:

  The TextInput slot is triggered when text input is received. Triggers after calling node:attachIME().

Signature:

["TextInput"]: function(text: string)

Parameters:

ParameterTypeDescription
textstringThe text that was input.

TextEditing

Type: Node Event.

Description:

  The TextEditing slot is triggered when text is being edited. Triggers after calling node:attachIME().

Signature:

["TextEditing"]: function(text: string, startPos: integer)

Parameters:

ParameterTypeDescription
textstringThe text that is being edited.
startPosintegerThe starting position of the text being edited.

ButtonDown

Type: Node Event.

Description:

  The ButtonDown slot is triggered when a game controller button is pressed down. Triggers after setting node.controllerEnabled = true.

Signature:

["ButtonDown"]: function(controllerId: integer, buttonName: Controller.ButtonName)

Parameters:

ParameterTypeDescription
controllerIdintegerThe controller id, incrementing from 0 when multiple controllers connected.
buttonNameKeyboard.KeyNameThe name of the button that was pressed.

ButtonUp

Type: Node Event.

Description:

  The ButtonUp slot is triggered when a game controller button is released. Triggers after setting node.controllerEnabled = true.

Signature:

["ButtonUp"]: function(controllerId: integer, buttonName: Controller.ButtonName)

Parameters:

ParameterTypeDescription
controllerIdintegerThe controller id, incrementing from 0 when multiple controllers connected.
buttonNameKeyboard.KeyNameThe name of the button that was released.

ButtonPressed

Type: Node Event.

Description:

  The ButtonPressed slot is triggered when a game controller button is being pressed down. Triggers after setting node.controllerEnabled = true.

Signature:

["ButtonPressed"]: function(controllerId: integer, buttonName: Controller.ButtonName)

Parameters:

ParameterTypeDescription
controllerIdintegerThe controller id, incrementing from 0 when multiple controllers connected.
buttonNameKeyboard.KeyNameThe name of the button that was pressed.

Axis

Type: Node Event.

Description:

  The Axis slot is triggered when a game controller axis changed. Triggers after setting node.controllerEnabled = true.

Signature:

["Axis"]: function(controllerId: integer, axisValue: number)

Parameters:

ParameterTypeDescription
controllerIdintegerThe controller id, incrementing from 0 when multiple controllers connected.
axisValuenumberThe controller axis value ranging from -1.0 to 1.0.